@extends('admin')
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="/">首页</a>
                <i class="icon-double-angle-right"></i>
                <span>订单</span>
            </li>

        </ul><!-- .breadcrumb -->

        <!-- #nav-search -->
    </div>

    <div class="page-content">

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <div class="row">
                    <div class="col-xs-12">
                        <h3 class="header smaller lighter blue">订单列表</h3>
                        <div class="table-header hidden">
                            订单搜索结果
                        </div>

                        <div class="table-responsive">
                            <table id="sample-table-2" class="table">
                                <thead>
                                <tr>
                                    <th class="center">
                                        <label>
                                            <input type="checkbox" class="ace" />
                                            <span class="lbl"></span>
                                        </label>
                                    </th>
                                    <th>商品</th>
                                    <th>单价</th>
                                    <th>数量</th>
                                    <th>实收款</th>
                                    <th class="hidden-480">交易状态</th>

                                    <th></th>
                                </tr>
                                </thead>

                                <tbody>
                                @if(!count($orderList))
                                    <tr>
                                        <td colspan="7" class="text-center">暂无数据</td>
                                    </tr>
                                @endif
                                @foreach($orderList as $order)
                                    <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace" value="{{ $order->id }}" />
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td>
                                        <img src="{{ $order->orderGoods->goods->pic }}" alt="{{ $order->orderGoods->goods->product->short }}">
                                        <span title="{{ $order->orderGoods->goods->product->title }}">{{ $order->orderGoods->goods->product->short }}</span>
                                    </td>
                                    <td>{{ $order->orderGoods->goods->price }}</td>
                                    <td>{{ $order->orderGoods->goods_num }}</td>
                                    <td>{{ $order->amount }}</td>

                                    <td class="hidden-480">
                                        <span class="label label-sm label-warning">{{ $order->status }}</span>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>



            </div><!-- /.col -->
        </div>
    </div><!-- /.page-content -->
@endsection
@section('include-script')
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/jquery.dataTables.bootstrap.js"></script>
@endsection
@section('custom-script')
    <script type="text/javascript">
        jQuery(function($) {

            $('table th input:checkbox').on('click' , function(){
                var that = this;
                $(this).closest('table').find('tr > td:first-child input:checkbox')
                        .each(function(){
                            this.checked = that.checked;
                            $(this).closest('tr').toggleClass('selected');
                        });

            });


            $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
            function tooltip_placement(context, source) {
                var $source = $(source);
                var $parent = $source.closest('table')
                var off1 = $parent.offset();
                var w1 = $parent.width();

                var off2 = $source.offset();
                var w2 = $source.width();

                if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
                return 'left';
            }
        })
    </script>
@endsection